## DESCRIPTION
## Algebra: an equation implicitly defining a function
## ENDDESCRIPTION

## KEYWORDS('algebra', 'equation implicitly defining a function')

## DBsubject('WeBWorK')
## DBchapter('WeBWorK Tutorial')
## DBsection('Fort Lewis Tutorial 2011')
## Date('01/30/2011')
## Author('Paul Pearson')
## Institution('Fort Lewis College')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')


####################################
#  Initialization

DOCUMENT();   

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserImplicitEquation.pl",
"AnswerFormatHelp.pl",
);     

TEXT(beginproblem());


##################################
#  Set-up

Context("ImplicitEquation");
Context()->{error}{msg}{
"Can't find any solutions to your equation"} = " ";
Context()->{error}{msg}{
"Can't generate enough valid points for comparison"} = " ";

Context()->variables->set(
  x=>{limits=>[-6,11]},
  y=>{limits=>[-6,11]},
);

$a = random(1,5,1);
$b = random(1,5,1);
$r = random(2,5,1);

$answer = ImplicitEquation(
  "(x-$a)^2 + (y-$b)^2 = $r^2",
  solutions=>[ 
     [$a,$b+$r],
     [$a,$b-$r],
     [$a+$r,$b],
     [$a-$r,$b],
     [$a+$r*sqrt(2)/2,$b+$r*sqrt(2)/2],
  ]
);


####################################
#  Main text

Context()->texStrings;
BEGIN_TEXT
Enter an equation for a circle in the xy-plane 
of radius \( $r \) centered at \( ($a,$b) \).
$BR
$BR
\{ ans_rule(40) \}
\{ AnswerFormatHelp("equation") \}
END_TEXT
Context()->normalStrings;


#####################################
#  Answer evaluation

$showPartialCorrectAnswers = 1;

ANS( $answer->cmp() );


#####################################
#  Solution

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT("MathObject version.");

ENDDOCUMENT();
